<script type="text/javascript" src="<?=base_url('assets/js/groups.js')?>"></script>

<div id="myModal" class="modal hide fade" style="display: none; ">
    <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal"></button>
      <h3>Grupos
	<i id="insert_icon" aria-hidden="true" class="icon-plus" style="margin-top: 6px; color: #5bb75b; display: none;"></i>  
	<i id="delete_icon" aria-hidden="true" class="icon-minus" style="margin-top: 6px; color: #bd362f; display: none;"></i>
	<i id="inform_icon" aria-hidden="true" class="icon-info-circle" style="margin-top: 6px; color: #24A0DA; display: none;"></i>
	<i id="update_icon" aria-hidden="true" class="icon-move-horizontal-alt2" style="margin-top: 6px; color: #f89406; display: none;"></i>
      </h3>
    </div>
    <div class="modal-body" style="min-height: 320px;">
	<input type="hidden" id="id_grupo">
	<input type="hidden" id="operation">
	<div id="error_msj" class="alert" style="display: none">Mensaje de error.
		<button class="close" data-dismiss="alert">&times;</button>
	</div>
      <table style="width: 100%">
	<tr>
	    <th>Nombre</th>
	    <td>&nbsp;&nbsp;<input type="text" id="descripcion" class="input-medim" placeholder="Nombre de grupo"></td>
	</tr>
	<tr>
            <td colspan="2" style="text-align: center">
                <div style="color: red" id="descripcion_error"></div>
            </td>
        </tr>
	<tr>
            <td colspan="2" style="text-align: center">
                <div style="color: red;" id="group_error"></div>
            </td>
        </tr>
	<tr>
            <td colspan="2" style="text-align: center" align="center">
			
			<?php
			if($menues != null)
			{
				echo '<div class="accordion" id="accordion2">';
				
				$indice = 0;
				$var = array("One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten");
				foreach($menues as $m)
				{

				echo '<div class="accordion-group">
					<div class="accordion-heading">';
					echo '<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapse'.$var[$indice].'" style="text-decoration:none">
						'.$m['description'].'
					      </a>';
				echo   '</div>';
				echo   '<div id="collapse'.$var[$indice].'" class="accordion-body collapse" style="height: 0px; ">
						<div class="accordion-inner">';
					foreach ($m['details'] as $d)
					{
						echo '<label style="padding-left: 200px; text-align: left;">
							<input type="checkbox" id="'.$d['menuTag'].'" name="'.$d['menuTag'].'" value="'.$d['menuId'].'">
							'.$d['description'].'
						      </label>';
					}
				echo 	'	</div>
					</div>
				      </div>';
				      $indice++;
				}
				echo '</div>';
			}
			else
			{
				echo "error al recuperar los datos.";
			}
			?>
		
            </td>
        </tr>
      </table>
    </div>
    <div class="modal-footer">
      <a href="#" class="btn" data-dismiss="modal">Cancelar</a>
      <a href="#" class="btn btn-primary" id="btnAceptar">Aceptar</a>
    </div>
</div>
        <!-- -->

<div class="container" id="containerDiv">
	<div class="row">
	    <div class="span1" title="Nuevo grupo">
		
		<button class="btn btn-success" data-toggle="modal" id="btnNewGroup">
		    Agregar
		</button>
			
	    </div>
	</div>
	
	<div class="row">
	    
	    <div class="span12">
		<table class="table">
		    <thead>
		    <tr>
			<th style="text-align: center; text-align: left; padding-left: 30px;">Nombre</th>
			<th style="text-align: center">Modificar</th>
			<th style="text-align: center">Eliminar</th>
			<th style="text-align: center">Consultar</th>
		    </tr>
		    </thead>
		    <tbody>
		    <?php
		    if($groups != null)
		    {
			foreach($groups as $g)
			{
			    echo '<tr>';
			    echo '<td>'.$g['gpoDescription'].'</td>';
			    echo '<td style="text-align: center" width="70">
					<i aria-hidden="true" class="icon-pencil" title="Modificar" onClick="Get_Data('.$g['gpoId'].',\'u\')" style="cursor: pointer;"></i>
				</td>';
			    echo '<td style="text-align: center" width="70">
					<i aria-hidden="true" class="icon-remove" title="Eliminar" onClick="Get_Data('.$g['gpoId'].',\'d\')" style="cursor: pointer;"></i>
				</td>';
			    echo '<td style="text-align: center" width="70">
					<i aria-hidden="true" class=" icon-search" title="Consultar" onClick="Get_Data('.$g['gpoId'].',\'s\')" style="cursor: pointer;"></i>
				</td>';
			    echo '</tr>';
			}
		    }
		    ?>
		    </tbody>
		</table>
		
	
	    </div>
	</div>
</div>